package ordinary;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Wukong
 * Date: 2022-06-03
 * Time: 18:10
 */
class Food{

}
class Fruit extends Food{

}
class Apple extends Fruit{

}
class Banana extends Fruit{

}
public class MessageTwo<T> {

    public T message;

    public T getMessage() {
        return message;
    }

    public void setMessage(T message) {
        this.message = message;
    }

    public static void main(String[] args) {
        Message<Apple> message=new Message<>();
        message.setMessage(new Apple());
        fun(message);
        Message<Banana> message2 = new Message<>() ;
        message2.setMessage(new Banana());
        fun(message2);
    }
    public static void fun(Message<? extends Fruit> message){
        System.out.println(message.getMessage());

    }



}
